package com.newsmanagement.controller.frontdesk;

import com.newsmanagement.common.Constants;
import com.newsmanagement.entity.ReturnedMessages;
import com.newsmanagement.service.INewsCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author xbr
 * 2017.12.04 11:24
 * 前台系统 新闻分类
 */
@Controller
@RequestMapping("newsCategoryFront")
public class NewsCategoryFrontController {

    @Autowired
    private INewsCategoryService newsCategoryService;

    /**
     * 设置个人感兴趣与不感兴趣的新闻分类
     * ids以英文逗号隔开
     * @param eumId 操作的用户id
     * @param categoryLikeIds 感兴趣的分类id集
     * @param categoryDislikeIds 不感兴趣的分类id集
     * @return
     * http://localhost:8080/newsCategoryFront/setCatatory?eumId=1&categoryLikeIds=1,2,6&categoryDislikeIds=3
     */
    @RequestMapping("setCategory")
    @ResponseBody
    public ReturnedMessages setCatatory(
            @RequestParam(value = "eumId") Integer eumId ,
            @RequestParam(value = "categoryLikeIds") String categoryLikeIds ,
            @RequestParam(value = "categoryDislikeIds") String categoryDislikeIds
    ){

        return newsCategoryService.setCatatory(eumId ,categoryLikeIds ,categoryDislikeIds);
    }


    /**
     * 查询新闻分类（过滤个人不感兴趣分类）
     * @param eumId 操作的用户id
     * @return
     * http://localhost:8080/newsCategoryFront/likeCategoryList?eumId=1&like=-1
     */
    @RequestMapping("likeCategoryList")
    @ResponseBody
    public ReturnedMessages likeCategoryList(
            @RequestParam(value = "eumId") Integer eumId
    ){

        return newsCategoryService.likeCategoryList(eumId , Constants.INT_ZERO);
    }

}
